import random

# String generate and lists data
randomString = '0123456789!@#$%^&*()_+?><=-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+?><=-'
randomStringLogin = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'

def getNameList():
    nameList = []

    with open('src/names.txt', 'r') as file:
        line = file.readline()
        while len(nameList) != 50:
            line = file.readline().replace('\n', '')
            nameList.append(line)

    return nameList

def getSurNameList():
    surNameList = []

    with open('src/surNames.txt', 'r') as file:
        line = file.readline()
        while len(surNameList) != 50:
            line = file.readline().replace('\n', '')
            surNameList.append(line)

    return surNameList

# Generates func
def generateName():
    return random.choice(nameList)

def generateSurName():
    return random.choice(surNameList)

def generateLogin():
    login_start = nameList[ random.randint(0, (len(nameList) - 1)) ]
    randomNumber = random.randint(3, 10)
    login_end = ''

    for i in range(0, randomNumber):
        login_end += randomStringLogin[random.randint(0, len(randomStringLogin) - 1)]
        i += 1

    return login_start + login_end

def generateDate():
    randomDay  = random.randint(1, 31)
    randomMoth = random.randint(1, 12)
    randomYear = random.randint(1990, 2010)
    return str(randomDay) + '.' + str(randomMoth) + '.' + str(randomYear)

def printdata(name, surname, login, date, password):
    border = ''
    while len(border) != len(password):
        border += '='
    border = '============' + border

    print(border)
    print('|> Name:    ' + name, surname)
    print('|> Date:    ' + date)
    print('|> Login:   ' + login)
    print('|> Pass:    ' + password)
    print('|> LenPass: ' + str(len(password)))
    print(border)

def generatePassword():
    while True:
        try:
            inputLengthPassword = input('Length Password: ')
            if (inputLengthPassword == 'q'): exit()
            elif (inputLengthPassword == ''): break

            inputLengthPassword = int(inputLengthPassword)
            break
        except Exception:
            print('Please input number')

    # Random length password
    if inputLengthPassword != '':
        randomLenPassword = inputLengthPassword
    else:
        randomLenPassword = random.randint(6, len(randomString))                 # max length auto random password

    randomPassword = ''
    while len(randomPassword) != int(randomLenPassword):
        randomPassword += randomString[random.randint(0, len(randomString) - 1)]

    return randomPassword


# Generate data
nameList       = getNameList()
surNameList    = getSurNameList()
randomName     = generateName()
randomSurName  = generateSurName()
randomLogin    = generateLogin()
randomDate     = generateDate()
randomPassword = generatePassword()

printdata(randomName, randomSurName, randomLogin, randomDate, randomPassword)
